package com.bang.study.test;

import com.bang.study.bean.Blue;
import com.bang.study.bean.Hadoop;
import com.bang.study.bean.Person;
import com.bang.study.config.AppConfig;
import com.bang.study.config.AppConfig2;
import com.bang.study.selector.MyFactoryBean;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @Auther: Bang
 * @Date: 2020/7/29 22:48
 * @Description:
 */
public class AppTest02 {


    @Test
    public void test01()  {
        AnnotationConfigApplicationContext ac =
                new AnnotationConfigApplicationContext(AppConfig2.class)
                ;
        String[] beanDefinitionNames = ac.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }
        Hadoop myFactoryBean = (Hadoop) ac.getBean("myFactoryBean");
        Hadoop myFactoryBean2 = (Hadoop) ac.getBean("myFactoryBean");
        System.out.println(myFactoryBean==myFactoryBean2);
        MyFactoryBean bean = (MyFactoryBean) ac.getBean("&myFactoryBean");
        System.out.println(bean);
        System.out.println(bean.getObjectType());
    }

    @Test
    public void test02()  {
        AnnotationConfigApplicationContext ac =
                new AnnotationConfigApplicationContext(AppConfig2.class)
                ;
        ac.close();

    }
}
